iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 6
1

前一天提到的Geocoding,是指從門牌中換算坐標
而在昨天測試的服務中也看到,這些服務不只門牌,也包含了地標POI

於是今天就來測試看看POI

選手1

首先登場的選手是Google,用的API跟昨天一樣(很方便)
基本題搜尋桃園國際機場

https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=桃園國際機場&inputtype=textquery&fields=formatted_address,name,rating,opening_hours,geometry&key=API_KEY

嗯,難不倒:

{
    "candidates": [
        {
            "formatted_address": "33758台灣桃園市大園區航站南路9號",
            "geometry": {
                "location": {
                    "lat": 25.0796514,
                    "lng": 121.234217
                },
                "viewport": {
                    "northeast": {
                        "lat": 25.10275,
                        "lng": 121.2624304
                    },
                    "southwest": {
                        "lat": 25.05372919999999,
                        "lng": 121.2032256
                    }
                }
            },
            "name": "臺灣桃園國際機場",
            "rating": 4.1
        }
    ],
    "status": "OK"
}

第二題,搜尋臺北市政府

https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=臺北市政府&inputtype=textquery&fields=formatted_address,name,rating,opening_hours,geometry&key=API_KEY

結果:

{
    "candidates": [
        {
            "formatted_address": "11008台灣台北市信義區市府路1號",
            "geometry": {
                "location": {
                    "lat": 25.0375417,
                    "lng": 121.5644327
                },
                "viewport": {
                    "northeast": {
                        "lat": 25.03888107989272,
                        "lng": 121.5664671
                    },
                    "southwest": {
                        "lat": 25.03618142010728,
                        "lng": 121.5625935
                    }
                }
            },
            "name": "臺北市政府",
            "opening_hours": {
                "open_now": false
            },
            "rating": 3.8
        }
    ],
    "status": "OK"
}

也沒問題,

再給一點變化,變成台北市政府

https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=台北市政府&inputtype=textquery&fields=formatted_address,name,rating,opening_hours,geometry&key=API_KEY

結果:

{
    "candidates": [
        {
            "formatted_address": "11008台灣台北市信義區市府路1號",
            "geometry": {
                "location": {
                    "lat": 25.0375417,
                    "lng": 121.5644327
                },
                "viewport": {
                    "northeast": {
                        "lat": 25.03888107989272,
                        "lng": 121.5664671
                    },
                    "southwest": {
                        "lat": 25.03618142010728,
                        "lng": 121.5625935
                    }
                }
            },
            "name": "臺北市政府",
            "opening_hours": {
                "open_now": false
            },
            "rating": 3.8
        }
    ],
    "status": "OK"
}

可以看得出來,資料庫存的是臺北市政府,但Google在語意網搜尋上很強,easy

選手2

緊接著,第二個選手
先測試第一題:

https://places.cit.api.here.com/places/v1/autosuggest?at=23,121
&q=桃園國際機場&app_id=APP_ID&app_code=APP_CODE

結果也是沒問題,資料庫存的不一樣,但是沒啥問題:

{
    "results": [
        {
            "title": "Taiwan Taoyuan International Airport (臺灣桃園國際機場)",
            "highlightedTitle": "Taiwan Taoyuan International Airport (臺灣桃園國際機場)",
            "vicinity": "9, 航站南路, 大園區, 桃園市",
            "highlightedVicinity": "9, 航站南路, 大園區, 桃園市",
            "position": [
                25.07938,
                121.23484
            ],
            
            略

第二題,測試臺北市政府

https://places.cit.api.here.com/places/v1/autosuggest?at=23,121
&q=臺北市政府&app_id=APP_ID&app_code=APP_CODE

結果如下:

{
    "results": [
        {
            "title": "政府 near Taipei City, Taiwan",
            "highlightedTitle": "<b>政府</b> near Taipei City, Taiwan",
            "category": "government-community-facility",
            "position": [
                25.03737,
                121.56355
            ],
            "href": "https://places.cit.api.here.com/places/v1/autosuggest/search;context=Zmxvdy1pZD00OWZjMThiYy0zNTlmLTUxYWItODVhMi1mY2ZmNDUyNTQyNjZfMTU2OTE2MDM5NDM2NV85MjA1XzM1MjgmcmFuaz0wJmF0PTIzLjAlMkMxMjEuMA?filters=lon%3A121.56355%2Ccategory%3Agovernment-community-facility%2Cvi%3Aautosuggest%2Clat%3A25.03737&app_id=APP_ID&app_code=APP_ID",
            "type": "urn:nlp-types:search",
            "resultType": "category",
            "distance": 232825
        },
        {
            "title": "Taipei City Police Department (臺北市政府警察局)",
            "highlightedTitle": "Taipei City Police Department (<b>臺北市</b>政府警察局)",
            "vicinity": "96, 延平南路, 光復里, 台北市",
            "highlightedVicinity": "96, 延平南路, 光復里, 台北市",
            "position": [
                25.04388,
                121.50982

略..

其實上面回應給了很多位置,但第一個建議的位置是差不多的(但可以看得出來中文搜尋還是有差)

選手3

接下來,直接上場地三位選手

https://api.tomtom.com/search/2/poiSearch/桃園國際機場.json?countrySet=TWN&limit=2&key=API_KEY

也是通過考驗:

{
    "summary": {
        "query": "桃園國際機場",
        "queryType": "NON_NEAR",
        "queryTime": 35,
        "numResults": 2,
        "offset": 0,
        "totalResults": 33,
        "fuzzyLevel": 1
    },
    "results": [
        {
            "type": "POI",
            "id": "TW/POI/p0/78050",
            "score": 13.52844,
            "info": "search:ta:158009000753020-TW",
            "poi": {
                "name": "台灣桃園國際機場, tai wan tao yuan guo ji ji chang",
                "phone": "+(886)-(3)-2733728",
                "categorySet": [
                    {
                        "id": 7383002
                    }
                ],
                "url": "www.taoyuan-airport.com",
                "categories": [
                    "airport",
                    "public authority"
                ],
                "classifications": [
                    {
                        "code": "AIRPORT",
                        "names": [
                            {
                                "nameLocale": "en-US",
                                "name": "airport"
                            },
                            {
                                "nameLocale": "en-US",
                                "name": "public authority"
                            }
                        ]
                    }
                ]
            },
            "address": {
                "streetNumber": "9",
                "streetName": "航站南路",
                "municipalitySubdivision": "大園區, da yuan qu",
                "municipality": "桃園市, 桃园市, tao yuan shi",
                "countrySubdivision": "桃園市, tao yuan shi",
                "postalCode": "337",
                "extendedPostalCode": "33758",
                "countryCode": "TW",
                "country": "Taiwan",
                "countryCodeISO3": "TWN",
                "freeformAddress": "桃園市 大園區 航站南路 9",
                "localName": "大園區"
            },
            "position": {
                "lat": 25.08103,
                "lon": 121.23698
            },
            "viewport": {
                "topLeftPoint": {
                    "lat": 25.08193,
                    "lon": 121.23599
                },
                "btmRightPoint": {
                    "lat": 25.08013,
                    "lon": 121.23797
                }
            },
            "entryPoints": [
                {
                    "type": "minor",
                    "position": {
                        "lat": 25.08132,
                        "lon": 121.2364
                    }
                },
                {
                    "type": "minor",
                    "position": {
                        "lat": 25.07781,
                        "lon": 121.23283
                    }
                },
                {
                    "type": "minor",
                    "position": {
                        "lat": 25.07699,
                        "lon": 121.23164
                    }
                },
                {
                    "type": "main",
                    "position": {
                        "lat": 25.08095,
                        "lon": 121.23674
                    }
                }
            ],
            "dataSources": {
                "geometry": {
                    "id": "00005457-3100-3c00-0000-0000596831c4"
                }
            }
        },

值得注意的事,細看資料發現不僅提供搜尋,還提供了其他資訊(如出入口等,我們過幾天討論)

一樣再測試臺北市政府

https://api.tomtom.com/search/2/poiSearch/臺北市政府.json?countrySet=TWN&limit=4&key=2GKtkrIduHYwsYmAIZjqeRc0f7YEIbYk

結果發現,語意搜尋上也是沒有那麼準,但至少有找到...

{
    "summary": {
        "query": "台 北 市 政 府",
        "queryType": "NON_NEAR",
        "queryTime": 42,
        "numResults": 4,
        "offset": 0,
        "totalResults": 257,
        "fuzzyLevel": 1
    },
    "results": [
        {
            "type": "POI",
            "id": "TW/POI/p0/59523",
            "score": 11.13824,
            "info": "search:ta:158009000843367-TW",
            "poi": {
                "name": "台北市政府舊廈, tai bei shi zheng fu jiu sha",
                "categorySet": [
                    {
                        "id": 7376002
                    }
                ],
                "categories": [
                    "building",
                    "important tourist attraction"
                ],
                "classifications": [
                    {
                        "code": "IMPORTANT_TOURIST_ATTRACTION",
                        "names": [
                            {
                                "nameLocale": "en-US",
                                "name": "important tourist attraction"
                            },
                            {
                                "nameLocale": "en-US",
                                "name": "building"
                            }
                        ]
                    }
                ]
         
          
          略...
        {
            "type": "POI",
            "id": "TW/POI/p0/192326",
            "score": 10.70793,
            "info": "search:ta:158008000011053-TW",
            "poi": {
                "name": "台北市政府, tai bei shi zheng fu",
                "phone": "+(886)-(2)-27208889",
                "categorySet": [
                    {
                        "id": 7367
                    }
                ],
                "url": "www.taipei.gov.tw",
                "categories": [
                    "government office"
                ],
                "classifications": [
                    {
                        "code": "GOVERNMENT_OFFICE",
                        "names": [
                            {
                                "nameLocale": "en-US",
                                "name": "government office"
                            }
                        ]
                    }
                ]
            },
            "address": {
                "streetNumber": "1",
                "streetName": "市府路",
                "municipalitySubdivision": "xin yi qu, 信義區",
                "municipality": "臺北市, 台北市, tai bei shi",
                "countrySubdivision": "台北市, tai bei shi",
                "postalCode": "110",
                "countryCode": "TW",
                "country": "Taiwan",
                "countryCodeISO3": "TWN",
                "freeformAddress": "台北市 xin yi qu 市府路 1",
                "localName": "xin yi qu, 信義區"
            },
            "position": {
                "lat": 25.03751,
                "lon": 121.56391
            },
            "viewport": {
                "topLeftPoint": {
                    "lat": 25.03841,
                    "lon": 121.56292
                },
                "btmRightPoint": {
                    "lat": 25.03661,
                    "lon": 121.5649
                }
            },
            "entryPoints": [
                {
                    "type": "main",
                    "position": {
                        "lat": 25.03868,
                        "lon": 121.56406
                    }
                }
            ]
        },
      略..
      
}

在POI搜尋上,主要不是位置精準度問題
而是在中文語意搜尋上有分高下(事實上資料庫專長也不同),如有需要可以稍加比較。


上一篇
Day05 Geocoding
系列文
30天探索物聯網時代的地圖應用6
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言